Lampen.h

					
#ifndef _LAMPEN_H_
#define _LAMPEN_H_

/******************* DEFINES *******************/

/* States of one separated Traffic light.
   Program switches cyclic between the states
 */
typedef enum
{
  ROT = 0x00,       // ROT
  ROT_GRUN = 0x01,  // ROT + GELB
  GRUN = 0x02,      // GRUN
  GRUN_ROT = 0x03,  // GELB
//  ALLE_AUS = 0x04,
} Ampel_state_t;

/******************* STRUCTURES, FUNKTION PROTOTYPES *******************/

/*  Structure for connecting pins of MCU and Program Logic
 *  describes one single traffic light (3 Lamps) on Potsdamer Platz
 *  For declaration - assign a corresponding output pin Numbers to a field
*/
struct One_ampel_struct
{
  uint8_t rot;  // Pin Number
  uint8_t gelb; // Pin Number
  uint8_t grun; // Pin Number

  Ampel_state_t current_state;
  Ampel_state_t future_state;

  uint16_t ticks; // for built in timer
//  uint8_t grun_blinken; // for blink count during color change
};

typedef struct One_ampel_struct one_ampel_t;

/*  Structure for connecting pins of MCU and Program Logic
 *  describes the whole Traffic Light on Potsdamer Platz
 *  For declaration - assign a corresponding output pin Numbers to a field
*/
struct Ampel_struct
{
  one_ampel_t ein_ampel[5]; 

  uint8_t curr_phase;          // Number of a Phase of traffic light (which streets are red and which are green) 

  uint16_t main_state_time;    // Times (mS) for States of traffic lights
  uint16_t transit_state_time;
 // uint16_t blink_state_time;
};

typedef struct Ampel_struct ampel_t;

void init_ampel(ampel_t* Ampel);

#endif /* _LAMPEN_H_ */